<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ObjectUtil</title>
</head>
<body>


<script src="../../../lib/baitu.min.js"></script>
<script>
    const {ObjectUtil} = Baitu;
    console.log(ObjectUtil.isEmpty())
    console.log(ObjectUtil.isEmpty(""))
    console.log(ObjectUtil.isEmpty([]))
    console.log(ObjectUtil.isEmpty({}))
    console.log(ObjectUtil.isEmpty(null))
    console.log(ObjectUtil.isEmpty(undefined))
    console.log(ObjectUtil.isEmpty("1"))
    console.log(ObjectUtil.isEmpty(["1"]))
    console.log(ObjectUtil.isEmpty({a: "2"}))

    console.log("deepCopy---------------")
    let obj1 = {
        p1: '1',
        p2: '2',
        p3: '3',
        p4: () => {
            return '5';
        }
    }

    let obj2 = {
        a1: 'a',
        a2: 'b'
    }

    let obj3 = {
        d1: obj1,
        ar: [obj1, obj2]
    }

    let obj4 = ObjectUtil.deepCopy(obj3)

    let obj5 = {
        f1: ObjectUtil.deepCopy(obj2)
    }

    obj1.p1 = '4'
    obj1.p4 = () => {
        return '6'
    }
    obj2.a1 = 'c'
    console.log(obj1)
    console.log(obj2)
    console.log(obj3)
    console.log(obj4)
    console.log(obj5)

    console.log(ObjectUtil.appendIfNotEmpty("苹果", "香蕉"))
    console.log(ObjectUtil.appendIfNotEmpty("", "香蕉"))
    console.log(ObjectUtil.appendIfNotEmpty(0, "香蕉"))
    console.log(ObjectUtil.appendIfNotEmpty(null, "香蕉"))
    console.log(ObjectUtil.appendIfNotEmpty({}, "香蕉"))

    console.log(ObjectUtil.compare(1, 2))
    console.log(ObjectUtil.compare(10, 2))
    console.log(ObjectUtil.compare(10, "2"))
    console.log(ObjectUtil.compare("10", 2))
    console.log(ObjectUtil.compare("10", "2"))
    console.log(ObjectUtil.compare("a", "b"))
    console.log(ObjectUtil.compare("b", "b"))
    console.log(ObjectUtil.compare("e", "b"))
    console.log(ObjectUtil.compare("edfs", "bdsf"))
</script>
</body>
</html>
